package com.imooc.controller;

import com.alibaba.csp.sentinel.EntryType;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description
 * @Author 顾志杰
 * @Date 2021/9/28 08:52
 */
@RestController
public class Controller {


    @GetMapping("/hello")
    @SentinelResource(value = "com.imooc.controller:hello",
            entryType = EntryType.OUT,
            blockHandler = "helloBlockHandier",
            fallback = "fallback"
    )
    public String hello() {
        return "hello";
    }

    public String helloBlockHandier(BlockException blockException) {
        return "hello降级";
    }

    public String fallback(Throwable throwable) {
        return "hello异常";
    }
}
